Skip to content

Conversation

ecordell
Copy link

@ecordell ecordell commented Sep 5, 2025

I found it frustrating that you couldn't run:

golangci-lint run --fix ../mydir

This PR adds support for this, by checking if ../mydir is part of a go module, finding the associated golangci config and running the configured linters.

For completeness, this PR also validates that all passed paths are part of the same module, and provides a nice error if not:

Example running against multiple modules:

$ golangci-lint run module1/subdir module2/subdir
ERRO Running error: context loading failed: failed to load packages: multiple Go modules detected: [/private/tmp/multi-subdir-test/module1 /private/tmp/multi-subdir-test/module2]

Multi-module analysis is not supported. Each module should be analyzed separately:
  golangci-lint run /private/tmp/multi-subdir-test/module1
  golangci-lint run /private/tmp/multi-subdir-test/module2

Example running against multiple packages in the same module:

$ golangci-lint run ../module/bar ../module/baz
../../../private/tmp/sibling-test/module/bar/main.go:1: : # testmodule/bar
bar/main.go:5:3: "os" imported and not used (typecheck)
package bar
../../../private/tmp/sibling-test/module/baz/main.go:1: : # testmodule/baz
baz/main.go:5:3: "os" imported and not used (typecheck)
package baz
2 issues:
* typecheck: 2

This doesn't directly address #828 but does make solving it a bit simpler (no need to change directories).

@CLAassistant
Copy link

CLAassistant commented Sep 5, 2025

CLA assistant check
All committers have signed the CLA.

@ecordell ecordell force-pushed the relative-paths branch 2 times, most recently from 170b6c8 to bef7b45 Compare September 5, 2025 15:02
@ldez ldez self-requested a review September 5, 2025 15:02
@ldez
Copy link
Member

ldez commented Sep 5, 2025

I don't understand your problem.

Why do you want to run golangci-lint on a parent or sibling directories of the location you are running it?

@ldez ldez added the waiting for: contributor feedback Requires additional feedback label Sep 5, 2025
@ldez ldez changed the title support running against golangci-lint against other directories support running against other directories Sep 5, 2025
@ldez ldez added declined and removed waiting for: contributor feedback Requires additional feedback labels Sep 5, 2025
@ldez
Copy link
Member

ldez commented Sep 5, 2025

  1. I don't understand the need
  2. It can create bugs/regressions
  3. It will have a notable impact on performance
  4. It breaks our tests.

I will decline this PR I recommend opening an issue to explain your problem, and we will discuss it inside this issue.

@ldez ldez closed this Sep 5, 2025
@mauriciabad

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants